<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>会员中心</title>

<link rel="stylesheet" type="text/css" href="${path}/statics/css/member/login/css.css">
<link rel="stylesheet" type="text/css" href="${path}/statics/css/member/login/center.css">
<link rel="stylesheet" href="${path}/statics/layui/css/layui.css">
</head>
<body>

	<!--导航-->
	<div class="dao_hang">
		<div class="nav_css">
	    	<!--会员中心-->
	    	<div class="important">
	    		 <img src="${path}/statics/img/member/login/all_list.png" style=" margin-top:13px">&nbsp;
	    		  会员中心
	      </div>
	      
	        <div class="dao_list">
	        	 <a href="javaScript:void(0)">
	        	  	<img src="${serverPath}/memberImg/${member.newFileName}" style="width: 40px;height: 40px; border-radius: 20px; "/>
	        	 </a>
	           <a href="javaScript:void(0)">${member.nickName}</a>
	           <a href="javaScript:void(0)" id="logOutBtn">退出</a>
	           <a href="${path}/frontCtl/toIndex">去首页</a>
	        </div>    
	    </div>
	</div>


<!--会员中心-->
<div class="centers_m">
	<!--左边导航菜单-->
    <div class="centers_ml">
        <!--列表go-->
        <div class="centers_listm">
        	<div class="centers_listm_one" >
        	
            	<img src="${path}/statics/img/member/login/zshy.png">
                <em>会员管理</em>
            </div>
            
            <!--资料管理开始-->
            <div class="centers_listm_one_in">
                <img src="${path}/statics/img/member/login/shezhi.png">
                <em>资料管理</em>
            </div>
            <span class="gjszmdm">
                <a href="${path}/memberCtl/memberInfo" class="center_in_self" target="workspace"><font>个人信息</font></a>
            </span>
            <!--账户安全开始-->
            <div class="centers_listm_one_in">
                <img src="${path}/statics/img/member/login/suo.png">
                <em>账户安全</em>
                <b></b>
            </div>
            <span class="gjszmdm">
                <a href="" class="center_in_self"><font>修改密码</font></a>
            </span>    
            <!--收藏管理开始-->
            <div class="centers_listm_one_in">
            <a>
                <img src="${path}/statics/img/member/login/wdssc.png">
                <em>收藏管理</em>
                <b></b>
            </div>
            <span class="gjszmdm">
            	<a href="${path}/memberCtl/toCollectList" class="center_in_self" target="workspace"><font>我的收藏</font></a>
            </span>    
            <!--评论管理开始-->
            <div class="centers_listm_one_in">
                <img src="${path}/statics/img/member/login/myfridend.png">
                <em>评论管理</em>
                <b></b>
            </div>
            <span class="gjszmdm">
            	<a href="${path}/memberCtl/toCommentList" class="center_in_self" target="workspace"><font>我的评论</font></a>
            </span>
        </div>
    </div>
    
    <!--右边操作区间-->
    <div class="centers_mr">
      <iframe name="workspace" src="${path}/memberCtl/toDefault" width="100%" height="100%"></iframe>
    </div>   
  </div>
</body>
</html>
	
<script src="${path}/statics/layui/layui.js"></script>
<script>
//JavaScript代码区域
layui.use(['laydate', 'laypage','element','jquery','layer','upload',"table"], function(){
  var element = layui.element;
  var $ = layui.jquery;
  var layer = layui.layer;
  var upload = layui.upload;
  var table = layui.table;
  var laydate = layui.laydate //日期
  ,laypage = layui.laypage //分页
 
  
  
  //点击查询按钮的处理事件
  $("#searchBtn").click(function(){
	 // alert();
	 
	 //重新加载表格,额外传递参数
	table.reload('tableId', {
 	    where: { //设定异步数据接口的额外参数，任意设
    	 nickName: $("#nickNameId").val()
    	,mobile: $("#mobileId").val()
    	//…
  	}
  	,page: {
  	   curr: 1 //重新从第 1 页开始
    }
	}); //只重载数据
	  
  });
  

  var active= {
  		  //重新加载表格数据,还是异步请求
  		  reloadTable:function(){
  			  table.reload('tableId', {
  				  page: {
  				    curr: 1 //重新从第 1 页开始
  				  }
  				}); //只重载数据
  		  },
  		  
	  		  
	  		 //发布与取消发布
	  		  pushAndCancel:function(status,data){
		  			//获取选中的行数的id值
		          	var ids = "";
		          	for(var i=0;i<data.length;i++){
		          		if (status == 1 && data[i].type == "禁用"){
		          			ids += data[i].id + ",";
		          		}
		          		if (status == 0 && data[i].type == "正常"){
		          			ids += data[i].id + ",";
		          		}
		          	}
  			  		alert(ids);
  	     	        $.post("${path}/memberCtl/pushAndCancel",{ids:ids,type:status},function(res){
  	     	        	
  	     	        	//返回状态码
  	     	        	if(res == 0){
  	     	        		layer.msg("操作成功",{icon:1},function(){
  	     	        			//因为在父级页面,所以不用parent.tools.function()
  	     	        			active.reloadTable();	
  	     	        		})
  	     	        	}else{
  	     	        		layer.msg("操作失败",{icon:5});
  	     	        	}
  	     	        	
  	     	       });
  		        
  		  	}
  }

  window.tools = active;
  
  //第一个实例
  table.render({
    elem: '#tableId'
    ,url: '${path}/memberCtl/list' //数据接口
    ,page: true //开启分页
    ,toolbar: '#headToolBar'
    ,limit: 5
    ,limits:[5,10,20,30,40,50,60]
    ,initSort:{
    	field: 'id' //排序字段
    	,type: 'desc'
    }
    ,cols: [[ //表头
      {type: 'checkbox', fixed: 'left'}
      ,{field: 'id', title: 'ID' ,sort:true ,width :60}
      ,{field: 'nick_name', title: '昵称' ,sort:true,width :120}
      ,{field: 'mobile', title: '电话' ,align:'center',width :120}
      ,{field: 'sex', title: '性别' ,width :60,align:'center',unresize:true}
      ,{field: 'address', title: '地址',sort:true,width :85,align:'center'}
      ,{field: 'type', title: '用户状态',width :85,align:'center'}
      ,{field: 'register_time', title: '最近登录时间',align:'center',width :120,sort:true,templet:function(row){
    	  //row表示当前行数据
    	  var date = new Date(row.register_time);
    	  return date.getFullYear()+"-"+date.getMonth()+"-"+date.getDate();
      }}
      ,{fixed: 'right', width: 165, align:'center', toolbar: '#rowToolBar'}
    ]]
  });
  
  
  
  //监听头工具栏事件
  table.on('toolbar(dataTable)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id)
    ,data = checkStatus.data; //获取选中的数据
    switch(obj.event){
      
      case 'push':
        if(data.length === 0){
          layer.msg('请至少选择一行');
        } else {
        	
        	active.pushAndCancel(1,data);
        }
      break;
      case 'cancel':
          if(data.length === 0){
            layer.msg('请至少选择一行');
          } else {
          	
        	  active.pushAndCancel(0,data);
          }
        break;
    };
  });
  
//安全退出
  $("#logOutBtn").click(function(){
  	   layer.confirm('您确定要退出吗?', function(index){
  		  location.replace("${path}/frontCtl/logOut");
  		  layer.close(index);
  		});  
  });
  
  
  
});


</script>



</body>
</html>